package com.xszx.statistics.controller;


import com.xszx.commonutils.R;
import com.xszx.statistics.service.StatisticsDailyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * <p>
 * 网站统计日数据 前端控制器
 * </p>
 *
 * @author 白熊
 * @since 2024-07-29
 */
@RestController
@RequestMapping("/statistics/statisticsDaily")
//@CrossOrigin
@Api(tags = "统计管理")
public class StatisticsDailyController {

    @Autowired
    private StatisticsDailyService statisticsDailyService;


    @GetMapping("showChart/{begin}/{end}/{type}")
    @ApiOperation("根据一段日期以及查询类型查询在线数")
    public R showChart(@PathVariable("begin") String begin,
                       @PathVariable("end") String end,
                       @PathVariable("type") String type){
        Map<String, Object> map = statisticsDailyService.getChartData(begin, end, type);
        return R.ok().data(map);
    }

    @PostMapping("{day}")
    @ApiOperation("根据日期查询注册人数")
    public R createStatisticsByDate(@PathVariable("day") String day) {
        statisticsDailyService.createStatisticsByDay(day);
        return R.ok();
    }

}

